package com.smartstate.dataManagement.exception;

/**
 * 异常编码
 */
public enum ErrorEnums {
    E_REQUEST_PARAMETERS("01", "请求参数有误"),
    CUSTOM("02", "数据已存在"),
    CUSTOM_DEVICEID("12", "设备编码已存在"),
    CUSTOM_DEVICENAME("02", "设备名称已存在"),
    RESOURCE_EXISTS("03", "查询资源不存在"),
    E_NO_AUTHORITY("06", "没有访问权限"),
    INVALID_OPERATION("07", "操作无效"),
    QUERY_OBJECT_NOT_EXIST("08", "对象不存在"),
    QUERY_OBJ_NOT_EXIST_INDEPENDENT_SCHEDULING("09", "查询对象无独立排班的父级对象"),
    INEXISTENCE_ERROR("45", "设备不存在"),
    SHIFT_TIME_LIST_IS_EMPTY("10", "班次时间List为空"),
    SHIFT_IN_FORCE_NOT_MODIFIED("11", "班次已生效,不能修改"),
    SHIFT_IN_FORCE_NOT_MODIFIED_REMOVE("12", "班次已生效,不能删除"),
    GRANULARITY_CANNOT_BE_EMPTY("13", "颗粒度不能为空"),
    QUERY_METER_NOT_EXIST("14", "表具不存在"),
    QUERY_OBJ_METER_NOT_EXIST("15", "查询对象下当前表具不存在"),
    ENTERPRISE_NOT_EXIST_OBJ("16", "企业下无对象"),
    QUERY_OBJ_NOT_EXIST_QUALIFIED_SHIFT("17", "查询对象无合格班次信息"),
    METER_NAME_CUSTOM("18", "表具名称已存在"),
    OBJ_NOTHAS_QUALIFIED_SONOBJ("19", "对象下无合格子对象"),
    SONOBJ_NOT_CONFIGURED_METER_MAP("20", "子对象未配置表具map"),
    NO_ELIGIBLE_OBJECT_LIST("21", "无合格对象列表"),
    OBJ_METER_MAP_JSON_NOT_CONFIGURED("22", "对象表具对应json未配置"),
    UNSORTED_OBJECT_LIST("23", "无排序对象列表"),
    CALCULATION_TIME_INTERVAL_IS_EMPTY("24", "计算时间区间为空"),
    EFFECTIVE_DATE_HAS_PASSED("25", "生效日期已过"),
    NOT_CONFIGURED("26", "采集器网关参数未配置"),
    CONFIGURED_TERMINATED("27", "此网关采集器已停用"),
    VIRTUAL_NOT_SECOND_DATA("28", "虚拟表无秒级数据"),
    RATE_CONTENT_IS_EMPTY("29", "费率内容为空"),
    RATE_SETTING_TIME_CONFLICT("30", "费率设置时间冲突"),
    RATE_IS_IN_EFFECT("31", "费率已生效"),
    OBJ_HAS_MEDIUMID_METER("32", "对象已绑定此介质"),
    FILE_READ_FAILURE("33", "文件读取失败"),
    NOT_DOWNLINK_TABLE_ATTRIBUTE("34", "下行表具属性不存在"),
    NOT("35", "设置值不在配置范围"),
    NOT_HAVE_ATTRIBUTE("36", "表具无此属性"),
    ATTRIBUTE_TYPE_E("37", "属性类型不一致"),
    PRODUCTION_NOT_SECOND_DATA("38", "产量表无秒级数据"),
    FORMULA_ERROR("39", "公式错误"),
    NO_DATA("39", "暂无数据"),
     DEVIATION_NOT_REASONABLE("52", "数据不合理"),
    DEVICE_ALARM("4040", "该设备暂无报警配置"),
    ATTRIBUTE_PRICE("41", "暂无计算公式"),
    ATTRIBUTE_NO("40", "请配置属性"),
    UNKNOWN("99", "未知错误");


    private String code;
    private String desc;

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    private ErrorEnums(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }


    public static ErrorEnums setErrorCode(String code) {
        for (ErrorEnums errorCode : ErrorEnums.values()) {
            if (errorCode.getCode() == code) {
                return errorCode;
            }
        }
        return null;
    }
}
